pull: Stop using GMainLoop
authorColin Walters <walters@verbum.org>
Wed, 12 Aug 2015 21:03:52 +0000 (17:03 -0400)
committerColin Walters <walters@verbum.org>
Fri, 14 Aug 2015 02:02:00 +0000 (22:02 -0400)
commit9f3d5869935c7f75fa06b0cfbabf9a49cd90f0f2
tree75b7f4050eb561a96103b345ca3a934e069e4fcb
parent5c20ea920e0986686b3bd680a43a1ab1cdde37ea
pull: Stop using GMainLoop

First of all, what we were doing with having GMainLoop in the internal
APIs is wrong.  Synchronous APIs should always create their own main
context and not iterate the caller's.  Doing the latter creates
potential for evil reentrancy issues.  Sync API should block, async
API is for not blocking.

Now that's out of the way, fix the pull code to do the clean

```
while (termination_condition (state))
  g_main_context_iteration (mainctx, TRUE);
```

model for looping.  This is a lot easier to understand and ultimately
more reliable than having other code call `g_main_loop_quit()`, as the
loop condition is in exactly one place.

We can also remove the idle source which only fired once.

Note we have to add a hack here to discard the synchronous session and
create a new one which we only use async.

https://bugzilla.gnome.org/show_bug.cgi?id=753336
src/libostree/ostree-fetcher.c
src/libostree/ostree-fetcher.h
src/libostree/ostree-metalink.c
src/libostree/ostree-metalink.h
src/libostree/ostree-repo-pull.c
src/libostree/ostree-repo.c